package cn.kgc.springboot.controller;

import cn.kgc.springboot.entity.User;
import cn.kgc.springboot.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 课工场
 * @date 2023/11/9
 * @description
 */
@Controller
@RequestMapping("hello")
public class HelloController {

    @Resource
    private UserService userService;

    @GetMapping
    @ResponseBody
    public String method1(){

        return "hello springboot";
    }


    @GetMapping("page")
    public String method2(Model model){

        List<User> users = userService.getList();
        model.addAttribute("users",users);
        return "hello";
    }
}
